using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Course_Assignment
    {
        public static bool Insert(Object tmp)
        {
            COURSE_ASSIGNMENT obj = (COURSE_ASSIGNMENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@ASSIGNMENT_END_DATE", obj.ASSIGNMENT_END_DATE));
            _list.Add(new SqlParameter("@ASSIGNMENT_ID", obj.ASSIGNMENT_ID));
            _list.Add(new SqlParameter("@ASSIGNMENT_START_DATE", obj.ASSIGNMENT_START_DATE));
            _list.Add(new SqlParameter("@COURSE_ID", obj.COURSE_ID));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));
            
            int n = clsDataAccessHelper.ExecNonQuery("sp_course_assignment_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            COURSE_ASSIGNMENT obj = (COURSE_ASSIGNMENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@ASSIGNMENT_END_DATE", obj.ASSIGNMENT_END_DATE));
            _list.Add(new SqlParameter("@ASSIGNMENT_ID", obj.ASSIGNMENT_ID));
            _list.Add(new SqlParameter("@ASSIGNMENT_START_DATE", obj.ASSIGNMENT_START_DATE));
            _list.Add(new SqlParameter("@COURSE_ID", obj.COURSE_ID));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));

            int n = clsDataAccessHelper.ExecNonQuery("sp_course_assignment_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            COURSE_ASSIGNMENT obj = (COURSE_ASSIGNMENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            //_list.Add(new SqlParameter("@ASSIGNMENT_END_DATE", obj.ASSIGNMENT_END_DATE));
            _list.Add(new SqlParameter("@ASSIGNMENT_ID", obj.ASSIGNMENT_ID));
            //_list.Add(new SqlParameter("@ASSIGNMENT_START_DATE", obj.ASSIGNMENT_START_DATE));
            //_list.Add(new SqlParameter("@COURSE_ID", obj.COURSE_ID));
            //_list.Add(new SqlParameter("@USER_ID", obj.USER_ID));

            int n = clsDataAccessHelper.ExecNonQuery("sp_course_assignment_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<COURSE_ASSIGNMENT> LoadAll()
        {
            List<COURSE_ASSIGNMENT> _list = new List<COURSE_ASSIGNMENT>();
            //call stored getlist here
            return _list;
        }
    }
}
